home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / tvision / tstrin / tvinput.dsk (.txt) < prev    next >
Encoding:
Turbo C Context File  |  1992-01-17  |  38.8 KB  |  977 lines

  1. Turbo C Context File 
  2. TVINPUT.CPP
  3. TSTRINP.CPP
  4. TVINPUT.CPP
  5. TSTRINP.CPP
  6. TVINPUT.CPP
  7. TSTRINP.CPP
  8. TVINPUT.CPP
  9. TSTRINP.CPP
  10. TVINPUT.CPP
  11. TSTRINP.CPP
  12. TVINPUT.CPP
  13. TSTRINP.CPP
  14. TVINPUT.CPP
  15. TSTRINP.CPP
  16. TVINPUT.CPP
  17. TSTRINP.CPP
  18. TVINPUT.CPP
  19. TSTRINP.CPP
  20. TVINPUT.CPP
  21. TSTRINP.CPP
  22. TVINPUT.CPP
  23. TSTRINP.CPP
  24. TVINPUT.CPP
  25. TSTRINP.CPP
  26. TVINPUT.CPP
  27. TSTRINP.CPP
  28. *.HPP
  29. *.CPP
  30. ofHaveInput
  31. ofMandInput
  32. left,D
  33. right
  34. right,D
  35. string
  36. D:\BC\TV\INCLUDE\MSGBOX.H
  37. D:\BC\TV\TVGAS\GASCALC.CPP
  38. D:\BC\TV\TSTRINP\TVINPUT.CPP
  39. D:\BC\TV\TSTRINP\TSTRINP.HPP
  40. D:\BC\TV\TSTRINP\TSTRINP.CPP
  41. _              &TFormApp::initMenuBar,
  42.               &TFormApp::initDeskTop)
  43.     TEvent event;
  44.     // Display about box
  45.     event.what = evCommand;
  46.     event.message.command = cmAboutBox;
  47.     putEvent(event);
  48. void TFormApp::changeDir()
  49.     TView *d = validView( new TChDirDialog( 0, hlChangeDir ) );
  50.     if( d != 0 ) {
  51.         deskTop->execView( d );
  52.         destroy(d);
  53.     }
  54. void TFormApp::dosShell()
  55.     suspend();
  56.     system("cls");
  57.     cout << "Type EXIT to return...";
  58.     system( getenv( "COMSPEC"));
  59.     resume();
  60.     redraw();
  61. void TFormApp::openListDialog()
  62.     TFileDialog *d;
  63.     char *fileName;
  64.     TDialog *listEditor;
  65.     char errorMsg[MAXSIZE];
  66.     extern Boolean fileExists( char *);
  67.     char name[MAXFILE];
  68.     char drive[MAXDRIVE];
  69.     char dir[MAXDIR];
  70.     char ext[MAXEXT];
  71.     d = new TFileDialog("*.TVF", "Open File",
  72.            "~N~ame", fdOpenButton, hlOpenListDlg);
  73.     if (validView(d) != NULL)
  74.         {
  75.         if (deskTop->execView(d) != cmCancel)
  76.             {
  77.             fileName = new char[MAXPATH];
  78.             d->getFileName(fileName);
  79.             if (!fileExists(fileName))
  80.                 {
  81.                 strcpy(errorMsg, "Cannot find file ");
  82.                 strcat(errorMsg, fileName);
  83.                 messageBox(errorMsg, mfError | mfOKButton);
  84.                 }
  85.             else
  86.                 {
  87.                 // If listEditor exists, select it; otherwise, open new one
  88.                 fnsplit(fileName, drive, dir, name, ext);
  89.                 listEditor = (TDialog *)message(deskTop, evBroadcast, cmEditingFile, fileName);
  90.                 if (listEditor == NULL)
  91.                     deskTop->insert(validView(new TListDialog(fileName, name)));
  92.                 else listEditor->select();
  93.                 }
  94.             delete fileName;
  95.             }
  96.         destroy(d);
  97.         }
  98. void TFormApp::handleEvent(TEvent& event)
  99.     ushort newMode;
  100.     char aboutMsg[80]; 
  101.     TApplication::handleEvent(event);
  102.     if (event.what == evCommand)
  103.         {
  104.         switch (event.message.command)
  105.             {
  106.             case cmListOpen:
  107.                 openListDialog();
  108.                 break;
  109.             case cmChgDir:
  110.                 changeDir();
  111.                 break;
  112.             case cmDosShell:
  113.                 dosShell();
  114.                 break;
  115.             case cmAboutBox:
  116.                 strcpy(aboutMsg, "\x3Turbo Vision C++ 1.0\n\n\x3Turbo Vision Forms Demo");
  117.                 messageBox(aboutMsg, mfInformation | mfOKButton);
  118.                 break;
  119.             case cmVideoMode:
  120.                 newMode = TScreen::screenMode ^ TDisplay::smFont8x8;
  121.                 if ((newMode & TDisplay::smFont8x8) != 0)
  122.                     shadowSize.x = 1;
  123.                 else
  124.                     shadowSize.x = 2;
  125.                 setScreenMode(newMode);
  126.                 break;
  127.             default:
  128.                 return; 
  129.             }
  130.         clearEvent(event);
  131.         }
  132. TMenuBar *TFormApp::initMenuBar( TRect r)
  133.     r.b.y = r.a.y + 1;
  134.     return new TMenuBar(r,
  135.       *new TSubMenu( "~\xF0~", hcNoContext ) +
  136.         *new TMenuItem( "~V~ideo mode", cmVideoMode, kbNoKey, hcNoContext, "" ) +
  137.              newLine() +
  138.         *new TMenuItem( "~A~bout...", cmAboutBox, kbNoKey, hcNoContext ) +
  139.       *new TSubMenu( "~F~ile", hcNoContext) +
  140.         *new TMenuItem( "~O~pen...", cmListOpen, kbF3, hcNoContext, "F3" ) +
  141.         *new TMenuItem( "~S~ave", cmListSave, kbF2, hcNoContext, "F2" ) +
  142.              newLine() +
  143.         *new TMenuItem( "~C~hange directory...", cmChgDir, kbNoKey, hcNoContext ) +
  144.         *new TMenuItem( "~D~OS shell", cmDosShell, kbNoKey, hcNoContext ) +
  145.         *new TMenuItem( "E~x~it", cmQuit, kbAltX, hcNoContext, "Alt-X" ) +
  146.       *new TSubMenu( "~W~indow", hcNoContext ) +
  147.         *new TMenuItem( "~M~ove", cmResize, kbCtrlF5, hcNoContext, "Cntl-F5") +
  148.         *new TMenuItem( "~N~ext", cmNext, kbF6, hcNoContext, "F6") +
  149.         *new TMenuItem( "~P~rev", cmPrev, kbShiftF6, hcNoContext, "Shift-F6") +
  150.         *new TMenuItem( "~C~lose", cmClose, kbAltF3, hcNoContext, "Alt-F3")
  151.       );
  152. TStatusLine *TFormApp::initStatusLine( TRect r )
  153.     r.a.y = r.b.y - 1;
  154.     return new TStatusLine( r,
  155.     *new TStatusDef( 0, 0xFFFF ) +
  156.       *new TStatusItem( "~F2~ Save", kbF2, cmListSave ) +
  157.       *new TStatusItem( "~F3~ Open", kbF3, cmListOpen ) +
  158.       *new TStatusItem( "~F10~ Menu", kbF10, cmMenu) +
  159.       *new TStatusItem( "", kbCtrlF5, cmResize )
  160.       );
  161. int main()
  162.     TFormApp formApp;
  163.     formApp.run();
  164.     return 0;
  165.    char *msg = " Prompt for...";
  166.    TDialog *d = new TDialog(TRect(0, 0, 30, 12), "Input form options");
  167.    d->options |= ofCentered;
  168.    d->insert(new TStaticText(TRect(2, 2, 17, 3), msg));
  169.    TView *v = new TCheckBoxes(TRect(2, 3, 28, 7),
  170.                               new TSItem("~O~il changes",
  171.                               new TSItem("~T~une-ups",
  172.                               new TSItem("~S~park plug changes",
  173.                               new TSItem("Oi~l~ brand/type", 0)))));
  174.    v->options |= ofFramed;
  175.    d->insert(v);
  176.    d->insert(new TButton(TRect(4, 9, 14, 11), "O~K~", cmOK, bfDefault));
  177.    d->insert(new TButton(TRect(16, 9, 26, 11), "~C~ancel",
  178.              cmCancel, bfNormal));
  179.    d->selectNext(True);
  180.    d->helpCtx = hcOPrefs;
  181.    // Execute the dialog box
  182.    execDialog(d, &boxes->init);
  183.    char label1[] = "~I~nput files extension";
  184.    char label2[] = "~R~eport files extension";
  185.    char label3[] = "~D~esktop files extension";
  186.    TInputLine *control;
  187.    TDialog *d = new TDialog(TRect(0, 0, 32, 18), "File extensions");
  188.    d->options |= ofCentered;
  189.    control = new TInputLine(TRect(2, 3, 8, 4), 4);
  190.    d->insert(control);
  191.    d->insert(new TLabel(TRect(2, 2, 30, 3), label1, control));
  192.    d->insert(new THistory(TRect(10, 3, 13, 4), control, hlInputExt));
  193.    control = new TInputLine(TRect(2, 7, 8, 8), 4);
  194.    d->insert(control);
  195.    d->insert(new TLabel(TRect(2, 6, 30, 7), label2, control));
  196.    d->insert(new THistory(TRect(10, 7, 13, 8), control, hlReportExt));
  197.    control = new TInputLine(TRect(2, 11, 8, 12), 4);
  198.    d->insert(control);
  199.    d->insert(new TLabel(TRect(2, 10, 30, 11), label3, control));
  200.    d->insert(new THistory(TRect(10, 11, 13, 12), control, hlDesktopExt));
  201.    d->insert(new TButton(TRect(3, 14, 13, 16), "O~K~", cmOK, bfDefault));
  202.    d->insert(new TButton(TRect(15, 14, 25, 16), "~C~ancel",
  203.                          cmCancel, bfNormal));
  204.    d->selectNext(True);
  205.    d->helpCtx = hcOPrefs;
  206.    if(execDialog(d, exts) != cmCancel)     // Execute dialog
  207.       {
  208.       strupr(exts->input);                 // Uppercase the data
  209.       strupr(exts->report);
  210.       strupr(exts->dsktop);
  211.       }
  212. ushort execDialog(TDialog *d, void *data)
  213. // Execute TDialog d with setData and getData
  214.    TView *p = TProgram::application->validView(d);
  215.    if(p == 0)
  216.       return cmCancel;
  217.    else
  218.       {
  219.       if(data != 0)
  220.          p->setData(data);
  221.       ushort result = TProgram::deskTop->execView(p);
  222.       if(result != cmCancel && data != 0)
  223.          p->getData(data);
  224.       TObject::destroy(p);
  225.       return result;
  226.       }
  227. messageBox("Couldn't open help file", mfError | mfOKButton);
  228. options |= ofSelectable | ofFirstClick;
  229. int dec, sign, ndig = 5;
  230. ndig, &dec, &sign);
  231. virtual void handleEvent( TEvent& event );
  232. void  TInputLine::handleEvent( TEvent& event )
  233.     TView::handleEvent(event);
  234.     int delta, anchor, i;
  235.     if( (state & sfSelected) != 0 )
  236.         switch( event.what )
  237.             {
  238.             case  evMouseDown:
  239.                 if( canScroll(delta = mouseDelta(event)) )
  240.                     do  {
  241.                         if( canScroll(delta) )
  242.                             {
  243.                             firstPos += delta;
  244.                             drawView();
  245.                             }
  246.                         } while( mouseEvent( event, evMouseAuto ) );
  247.                 else if (event.mouse.doubleClick)
  248.                         selectAll(True);
  249.                 else
  250.                     {
  251.                     anchor =  mousePos(event);
  252.                     do  {
  253.                         if( event.what == evMouseAuto &&
  254.                             canScroll( delta = mouseDelta(event) )
  255.                           )
  256.                             firstPos += delta;
  257.                         curPos = mousePos(event);
  258.                         if( curPos < anchor )
  259.                             {
  260.                             selStart = curPos;
  261.                             selEnd = anchor;
  262.                             }
  263.                         else
  264.                             {
  265.                             selStart = anchor;
  266.                             selEnd = curPos;
  267.                             }
  268.                         drawView();
  269.                         } while (mouseEvent(event, evMouseMove | evMouseAuto));
  270.                     }
  271.                 clearEvent(event);
  272.                 break;
  273.             case  evKeyDown:
  274.                 switch( ctrlToArrow(event.keyDown.keyCode) )
  275.                     {
  276.                     case kbLeft:
  277.                         if( curPos > 0 )
  278.                             curPos--;
  279.                         break;
  280.                     case kbRight:
  281.                         if( curPos < strlen(data) )
  282.                             curPos++;
  283.                         break;
  284.                     case kbHome:
  285.                         curPos =  0;
  286.                         break;
  287.                     case kbEnd:
  288.                         curPos = strlen(data);
  289.                         break;
  290.                     case kbBack:
  291.                         if( curPos > 0 )
  292.                             {
  293.                             strcpy( data+curPos-1, data+curPos );
  294.                             curPos--;
  295.                             if( firstPos > 0 )
  296.                                 firstPos--;
  297.                             }
  298.                         break;
  299.                     case kbDel:
  300.                         if( selStart == selEnd )
  301.                             if( curPos < strlen(data) )
  302.                                 {
  303.                                 selStart = curPos;
  304.                                 selEnd = curPos + 1;
  305.                                 }
  306.                         deleteSelect();
  307.                         break;
  308.                     case kbIns:
  309.                         setState(sfCursorIns, Boolean(!(state & sfCursorIns)));
  310.                         break;
  311.                     default:
  312.                         if( event.keyDown.charScan.charCode >= ' ' )
  313.                             {
  314.                             if( (state & sfCursorIns) != 0 )
  315.                                 strcpy( data + curPos, data + curPos + 1 );
  316.                             else
  317.                                 deleteSelect();
  318.                             if( strlen(data) < maxLen )
  319.                                 {
  320.                                 if( firstPos > curPos )
  321.                                     firstPos = curPos;
  322.                                 memmove( data + curPos + 1, data + curPos,
  323.                                          strlen(data+curPos)+1 );
  324.                                 data[curPos++] =
  325.                                     event.keyDown.charScan.charCode;
  326.                                 }
  327.                             }
  328.                         else if( event.keyDown.charScan.charCode == CONTROL_Y)
  329.                             {
  330.                             *data = EOS;
  331.                             curPos = 0;
  332.                             }
  333.                         else
  334.                             return;
  335.                     }
  336.                     selStart = 0;
  337.                     selEnd = 0;
  338.                     if( firstPos > curPos )
  339.                         firstPos = curPos;
  340.                     i = curPos - size.x + 3;
  341.                     if( firstPos < i )
  342.                         firstPos = i;
  343.                     drawView();
  344.                     clearEvent( event );
  345.                     break;
  346.             }
  347.    if(event.what == evCommand && event.message.command == cmClose)
  348. __link(RInputLine)
  349. f(ios::showpos) ;
  350. f(ios::showpos) ;
  351. str.setf(ios::showpoint) ;
  352. os.setf(ios::showpoint);
  353. os.setf(ios::showpos);
  354. os.setf(ios::showpoint);
  355.          os.setf(ios::showpos);
  356.          
  357. cout.precision(1) ;
  358. cout.setf(ios::fixed , ios::floatfield) ;
  359. os.setf(ios::fixed, ios::floatfield);
  360.          os.setf(ios::showpoint);
  361.          os.precision(1) ;
  362.          
  363. os.setf(ios::showpos);
  364.    char buff[81];
  365.    ostrstream os(buff, sizeof buff);
  366.    os.setf(ios::showpoint);
  367.    os.setf(ios::fixed, ios::floatfield);
  368.    os.precision(1) ;
  369.    os << *(double *)rec
  370.       << ends;
  371.    strcpy(data, os.str());
  372.    os.setf(ios::showpoint);
  373.    os.setf(ios::fixed, ios::floatfield);
  374.    os.precision(1) ;
  375.    os << *(double *)rec
  376.       << ends;
  377.    strcpy(data, os.str());
  378. #if !defined __VALUES_H
  379. #include <values.h>
  380. #endif
  381. #if !defined __IOSTREAM_H
  382. #include <iostream.h>
  383. #endif
  384. #if !defined __IOMANIP_H
  385. #include <iomanip.h>
  386. #endif
  387. #define Uses_ipstream
  388. #define Uses_opstream
  389.                     
  390. ofCentered    = 0x300
  391. ofSelectable  = 0x001
  392.           
  393.          
  394. ofTopSelect   = 0x002
  395.        Udefned      
  396. ofFirstClick  = 0x004
  397.                     
  398. ofFramed      = 0x008
  399.                     
  400. ofPreProcess  = 0x010
  401.                     
  402. ofPostProcess = 0x020
  403.                     
  404. ofBuffered    = 0x040
  405.                     
  406. ofTileable    = 0x080
  407.                     
  408. ofCenterX     = 0x100
  409.                     
  410. ofCenterY     = 0x200
  411. d->insert(new THistory(TRect(10, 3, 13, 4), control, hlInputExt));
  412. if( (state & sfSelected) != 0 )
  413.         switch( event.what )
  414.             {
  415.             case  evMouseDown:
  416.                 if( canScroll(delta = mouseDelta(event)) )
  417.                     do  {
  418.                         if( canScroll(delta) )
  419.                             {
  420.                             firstPos += delta;
  421.                             drawView();
  422.                             }
  423.                         } while( mouseEvent( event, evMouseAuto ) );
  424.                 else if (event.mouse.doubleClick)
  425.                         selectAll(True);
  426.                 else
  427.                     {
  428.                     anchor =  mousePos(event);
  429.                     do  {
  430.                         if( event.what == evMouseAuto &&
  431.                             canScroll( delta = mouseDelta(event) )
  432.                           )
  433.                             firstPos += delta;
  434.                         curPos = mousePos(event);
  435.                         if( curPos < anchor )
  436.                             {
  437.                             selStart = curPos;
  438.                             selEnd = anchor;
  439.                             }
  440.                         else
  441.                             {
  442.                             selStart = anchor;
  443.                             selEnd = curPos;
  444.                             }
  445.                         drawView();
  446.                         } while (mouseEvent(event, evMouseMove | evMouseAuto));
  447.                     }
  448.                 clearEvent(event);
  449.                 break;
  450.             case  evKeyDown:
  451.                 switch( ctrlToArrow(event.keyDown.keyCode) )
  452.                     {
  453.                     case kbLeft:
  454.                         if( curPos > 0 )
  455.                             curPos--;
  456.                         break;
  457.                     case kbRight:
  458.                         if( curPos < strlen(data) )
  459.                             curPos++;
  460.                         break;
  461.                     case kbHome:
  462.                         curPos =  0;
  463.                         break;
  464.                     case kbEnd:
  465.                         curPos = strlen(data);
  466.                         break;
  467.                     case kbBack:
  468.                         if( curPos > 0 )
  469.                             {
  470.                             strcpy( data+curPos-1, data+curPos );
  471.                             curPos--;
  472.                             if( firstPos > 0 )
  473.                                 firstPos--;
  474.                             }
  475.                         break;
  476.                     case kbDel:
  477.                         if( selStart == selEnd )
  478.                             if( curPos < strlen(data) )
  479.                                 {
  480.                                 selStart = curPos;
  481.                                 selEnd = curPos + 1;
  482.                                 }
  483.                         deleteSelect();
  484.                         break;
  485.                     case kbIns:
  486.                         setState(sfCursorIns, Boolean(!(state & sfCursorIns)));
  487.                         break;
  488.                     default:
  489.                         if( event.keyDown.charScan.charCode >= ' ' )
  490.                             {
  491.                             if( (state & sfCursorIns) != 0 )
  492.                                 strcpy( data + curPos, data + curPos + 1 );
  493.                             else
  494.                                 deleteSelect();
  495.                             if( strlen(data) < maxLen )
  496.                                 {
  497.                                 if( firstPos > curPos )
  498.                                     firstPos = curPos;
  499.                                 memmove( data + curPos + 1, data + curPos,
  500.                                          strlen(data+curPos)+1 );
  501.                                 data[curPos++] =
  502.                                     event.keyDown.charScan.charCode;
  503.                                 }
  504.                             }
  505.                         else if( event.keyDown.charScan.charCode == CONTROL_Y)
  506.                             {
  507.                             *data = EOS;
  508.                             curPos = 0;
  509.                             }
  510.                         else
  511.                             return;
  512.                     }
  513.                     selStart = 0;
  514.                     selEnd = 0;
  515.                     if( firstPos > curPos )
  516.                         firstPos = curPos;
  517.                     i = curPos - size.x + 3;
  518.                     if( firstPos < i )
  519.                         firstPos = i;
  520.                     drawView();
  521.                     clearEvent( event );
  522.                     break;
  523.             }
  524. if( event.what == evMouseDown ||
  525.           ( event.what == evKeyDown &&
  526.             ctrlToArrow( event.keyDown.keyCode ) ==  kbDown &&
  527.             (link->state & sfFocused) != 0
  528.           )
  529.       )
  530. if( event.what == evBroadcast )
  531.             if( (event.message.command == cmReleasedFocus &&
  532.                  event.message.infoPtr ==  link) ||
  533.                 event.message.command ==  cmRecordHistory
  534.               )
  535. if( event.what == evMouseDown ||
  536.           ( event.what == evKeyDown &&
  537.             ctrlToArrow( event.keyDown.keyCode ) ==  kbDown &&
  538.             (link->state & sfFocused) != 0
  539. eventMask |= evBroadcast;
  540. class far THistoryWindow;
  541.     if( event.what == evMouseDown ||
  542.           ( event.what == evKeyDown &&
  543.             ctrlToArrow( event.keyDown.keyCode ) ==  kbDown &&
  544.             (link->state & sfFocused) != 0
  545.           )
  546.       )
  547.         {
  548.         link->select();
  549.         historyAdd( historyId, link->data );
  550.         r = link->getBounds();
  551.         r.a.x--;
  552.         r.b.x++;
  553.         r.b.y += 7;
  554.         r.a.y--;
  555.         p = owner->getExtent();
  556.         r.intersect( p );
  557.         r.b.y--;
  558.         historyWindow = initHistoryWindow( r );
  559.         if( historyWindow != 0 )
  560.             {
  561.             c = owner->execView( historyWindow );
  562.             if( c == cmOK )
  563.                 {
  564.                 char rslt[256];
  565.                 historyWindow->getSelection( rslt );
  566.                 strncpy( link->data, rslt, link->maxLen );
  567.                 link->selectAll( True );
  568.                 link->drawView();
  569.                 }
  570.             destroy( historyWindow );
  571.             }
  572.         clearEvent( event );
  573.         }
  574.     else
  575.         if( event.what == evBroadcast )
  576.             if( (event.message.command == cmReleasedFocus &&
  577.                  event.message.infoPtr ==  link) ||
  578.                 event.message.command ==  cmRecordHistory
  579.               )
  580.                 historyAdd( historyId, link->data );
  581. keyDown.keyCode = _AX;
  582.     while( curRec != 0 )
  583.         {
  584.         if( strcmp( str, curRec->str ) == 0 )
  585.             deleteString();
  586.         advanceStringPointer();
  587.         }
  588. event.keyDown.charScan.charCode;
  589. if( (state & sfSelected) != 0 )
  590.         switch( event.what )
  591.     for( short i = 0; i <= index; i++ )
  592. advanceStringPointer();
  593.     while( curRec != 0 )
  594.         {
  595.         if( strcmp( str, curRec->str ) == 0 )
  596.             deleteString();
  597.         advanceStringPointer();
  598. advanceStringPointer();
  599.     while( curRec != 0 )
  600.         {
  601.         if( strcmp( str, curRec->str ) == 0 )
  602.             deleteString();
  603.         advanceStringPointer();
  604.     if( event.what == evMouseDown ||
  605.           ( event.what == evKeyDown &&
  606.             ctrlToArrow( event.keyDown.keyCode ) ==  kbDown &&
  607.             (link->state & sfFocused) != 0
  608.           )
  609.       )
  610.         {
  611.         link->select();
  612.         historyAdd( historyId, link->data );
  613.         r = link->getBounds();
  614.         r.a.x--;
  615.         r.b.x++;
  616.         r.b.y += 7;
  617.         r.a.y--;
  618.         p = owner->getExtent();
  619.         r.intersect( p );
  620.         r.b.y--;
  621.         historyWindow = initHistoryWindow( r );
  622.         if( historyWindow != 0 )
  623.             {
  624.             c = owner->execView( historyWindow );
  625.             if( c == cmOK )
  626.                 {
  627.                 char rslt[256];
  628.                 historyWindow->getSelection( rslt );
  629.                 strncpy( link->data, rslt, link->maxLen );
  630.                 link->selectAll( True );
  631.                 link->drawView();
  632.                 }
  633.             destroy( historyWindow );
  634.             }
  635.         clearEvent( event );
  636.         }
  637.     else
  638.         if( event.what == evBroadcast )
  639.             if( (event.message.command == cmReleasedFocus &&
  640.                  event.message.infoPtr ==  link) ||
  641.                 event.message.command ==  cmRecordHistory
  642.               )
  643.                 historyAdd( historyId, link->data );
  644.     TView::handleEvent(event);
  645.     int delta, anchor, i;
  646.     if( (state & sfSelected) != 0 )
  647.         switch( event.what )
  648.             {
  649.             case  evMouseDown:
  650.                 if( canScroll(delta = mouseDelta(event)) )
  651.                     do  {
  652.                         if( canScroll(delta) )
  653.                             {
  654.                             firstPos += delta;
  655.                             drawView();
  656.                             }
  657.                         } while( mouseEvent( event, evMouseAuto ) );
  658.                 else if (event.mouse.doubleClick)
  659.                         selectAll(True);
  660.                 else
  661.                     {
  662.                     anchor =  mousePos(event);
  663.                     do  {
  664.                         if( event.what == evMouseAuto &&
  665.                             canScroll( delta = mouseDelta(event) )
  666.                           )
  667.                             firstPos += delta;
  668.                         curPos = mousePos(event);
  669.                         if( curPos < anchor )
  670.                             {
  671.                             selStart = curPos;
  672.                             selEnd = anchor;
  673.                             }
  674.                         else
  675.                             {
  676.                             selStart = anchor;
  677.                             selEnd = curPos;
  678.                             }
  679.                         drawView();
  680.                         } while (mouseEvent(event, evMouseMove | evMouseAuto));
  681.        
  682. 1             }
  683.                 clearEvent(event);
  684.                 break;
  685.             case  evKeyDown:
  686.                 switch( ctrlToArrow(event.keyDown.keyCode) )
  687.                     {
  688.                     case kbLeft:
  689.                         if( curPos > 0 )
  690.                             curPos--;
  691.                         break;
  692.                     case kbRight:
  693.                         if( curPos < strlen(data) )
  694.                             curPos++;
  695.                         break;
  696.                     case kbHome:
  697.                         curPos =  0;
  698.                         break;
  699.                     case kbEnd:
  700.                         curPos = strlen(data);
  701.                         break;
  702.                     case kbBack:
  703.                         if( curPos > 0 )
  704.                             {
  705.                             strcpy( data+curPos-1, data+curPos );
  706.                             curPos--;
  707.                             if( firstPos > 0 )
  708.                                 firstPos--;
  709.                             }
  710.                         break;
  711.                     case kbDel:
  712.                         if( selStart == selEnd )
  713.                             if( curPos < strlen(data) )
  714.                                 {
  715.                                 selStart = curPos;
  716.                                 selEnd = curPos + 1;
  717.                                 }
  718.                         deleteSelect();
  719.                         break;
  720.                     case kbIns:
  721.                         setState(sfCursorIns, Boolean(!(state & sfCursorIns)));
  722.                         break;
  723.                     default:
  724.                         if( event.keyDown.charScan.charCode >= ' ' )
  725.                             {
  726.                             if( (state & sfCursorIns) != 0 )
  727.                                 strcpy( data + curPos, data + curPos + 1 );
  728.                             else
  729.                                 deleteSelect();
  730.                             if( strlen(data) < maxLen )
  731.                                 {
  732.                                 if( firstPos > curPos )
  733.                                     firstPos = curPos;
  734.                                 memmove( data + curPos + 1, data + curPos,
  735.                                          strlen(data+curPos)+1 );
  736.                                 data[curPos++] =
  737.                                     event.keyDown.charScan.charCode;
  738.                                 }
  739.                             }
  740.                         else if( event.keyDown.charScan.charCode == CONTROL_Y)
  741.                             {
  742.                             *data = EOS;
  743.                             curPos = 0;
  744.                             }
  745.                         else
  746.                             return;
  747.                     }
  748.                     selStart = 0;
  749.                     selEnd = 0;
  750.                     if( firstPos > curPos )
  751.                         firstPos = curPos;
  752.                     i = curPos - size.x + 3;
  753.                     if( firstPos < i )
  754.                         firstPos = i;
  755.                     drawView();
  756.                     clearEvent( event );
  757.                     break;
  758.             }
  759. #define Uses_TKeys
  760.     TView::handleEvent(event);
  761.     int delta, anchor, i;
  762.     if( (state & sfSelected) != 0 )
  763.         switch( event.what )
  764.             {
  765.             case  evMouseDown:
  766.                 if( canScroll(delta = mouseDelta(event)) )
  767.                     do  {
  768.                         if( canScroll(delta) )
  769.                             {
  770.                             firstPos += delta;
  771.                             drawView();
  772.                             }
  773.                         } while( mouseEvent( event, evMouseAuto ) );
  774.                 else if (event.mouse.doubleClick)
  775.                         selectAll(True);
  776.                 else
  777.                     {
  778.                     anchor =  mousePos(event);
  779.                     do  {
  780.                         if( event.what == evMouseAuto &&
  781.                             canScroll( delta = mouseDelta(event) )
  782.                           )
  783.                             firstPos += delta;
  784.                         curPos = mousePos(event);
  785.                         if( curPos < anchor )
  786.                             {
  787.                             selStart = curPos;
  788.                             selEnd = anchor;
  789.                             }
  790.                         else
  791.                             {
  792.                             selStart = anchor;
  793.                             selEnd = curPos;
  794.                             }
  795.                         drawView();
  796.                         } while (mouseEvent(event, evMouseMove | evMouseAuto));
  797.                     }
  798.                 clearEvent(event);
  799.                 break;
  800.             case  evKeyDown:
  801.                 switch( ctrlToArrow(event.keyDown.keyCode) )
  802.                     {
  803.                     case kbLeft:
  804.                         if( curPos > 0 )
  805.                             curPos--;
  806.                         break;
  807.                     case kbRight:
  808.                         if( curPos < strlen(data) )
  809.                             curPos++;
  810.                         break;
  811.                     case kbHome:
  812.                         curPos =  0;
  813.                         break;
  814.                     case kbEnd:
  815.                         curPos = strlen(data);
  816.                         break;
  817.                     case kbBack:
  818.                         if( curPos > 0 )
  819.                             {
  820.                             strcpy( data+curPos-1, data+curPos );
  821.                             curPos--;
  822.                             if( firstPos > 0 )
  823.                                 firstPos--;
  824.                             }
  825.                         break;
  826.                     case kbDel:
  827.                         if( selStart == selEnd )
  828.                             if( curPos < strlen(data) )
  829.                                 {
  830.                                 selStart = curPos;
  831.                                 selEnd = curPos + 1;
  832.                                 }
  833.                         deleteSelect();
  834.                         break;
  835.                     case kbIns:
  836.                         setState(sfCursorIns, Boolean(!(state & sfCursorIns)));
  837.                         break;
  838.                     default:
  839.                         if( event.keyDown.charScan.charCode >= ' ' )
  840.                             {
  841.                             if( (state & sfCursorIns) != 0 )
  842.                                 strcpy( data + curPos, data + curPos + 1 );
  843.                             else
  844.                                 deleteSelect();
  845.                             if( strlen(data) < maxLen )
  846.                                 {
  847.                                 if( firstPos > curPos )
  848.                                     firstPos = curPos;
  849.                                 memmove( data + curPos + 1, data + curPos,
  850.                                          strlen(data+curPos)+1 );
  851.                                 data[curPos++] =
  852.                                     event.keyDown.charScan.charCode;
  853.                                 }
  854.                             }
  855.                         else if( event.keyDown.charScan.charCode == CONTROL_Y)
  856.                             {
  857.                             *data = EOS;
  858.                             curPos = 0;
  859.                             }
  860.                         else
  861.                             return;
  862.                     }
  863.                     selStart = 0;
  864.                     selEnd = 0;
  865.                     if( firstPos > curPos )
  866.                         firstPos = curPos;
  867.                     i = curPos - size.x + 3;
  868.                     if( firstPos < i )
  869.                         firstPos = i;
  870.                     drawView();
  871.                     clearEvent( event );
  872.                     break;
  873.             }
  874. The options word flags determine various behaviors of the view. The options
  875. bits are defined as follows:
  876.                    
  877. ofCentered    = 0x300
  878.  15 14 13 12 11 10 9   8   7  6  5  4  3  2  1  0
  879. ofSelectable  = 0x001
  880. ofTopSelect   = 0x002
  881. ofFirstClick  = 0x004
  882. ofFramed      = 0x008
  883. ofPreProcess  = 0x010
  884. ofPostProcess = 0x020
  885. ofBuffered    = 0x040
  886. ofTileable    = 0x080
  887. ofCenterX     = 0x100
  888. ofCenterY     = 0x200
  889. ofHaveInput   = 0x400
  890. Undefined     = 0x800
  891. Undefined     = 0x1000
  892. Undefined     = 0x2000
  893. Undefined     = 0x4000
  894. Undefined     = 0x8000
  895. The following is a graphical representation of the defined and
  896. undefined bits in the 'TView::options' data member.
  897. long ios::setf(long _setbits, long _field)
  898.     long x = x_flags;
  899.     x_flags &= ~_field;
  900.     x_flags |= (_setbits & _field);
  901.     if( x_flags & ios::skipws )
  902.         ispecial |= skipping;
  903.     else
  904.         ispecial &= ~skipping;
  905.     return x;
  906. long TStringInputLine::setViewOpt(long setbits)
  907. // Define THistory ID for TStringInputLine
  908. const ushort hlStrInpLine = 100;
  909. // Look for misplaced period in the string
  910.          char *ptr = strpbrk(data, "eE");
  911.          if((ptr) && (strpbrk(ptr, ".")))
  912.             invalid = True;
  913. = (double) atof(data);
  914. (ch != '-')    &&       // and not a -...
  915.                (ch != '+')    &&       // and not a +...
  916. #if !defined __FLOAT_H
  917. #include <float.h>
  918. #endif
  919.     TEvent event;
  920.     // Display about box
  921.     event.what = evCommand;
  922.     event.message.command = cmAboutBox;
  923.     putEvent(event);
  924. event.message.command = cmAboutBox;
  925. if( event.what == evCommand && event.message.command == cmQuit )
  926.         {
  927.         endModal( cmQuit );
  928.         clearEvent( event );
  929.         }
  930. ushort result = TProgram::deskTop->execView(p);
  931. #define LN_MAXDOUBLE    7.0978E+2
  932. #define LN_MINDOUBLE    -7.0840E+2
  933. 1.797693E+308
  934.   void
  935.   setState(ushort aState, Boolean enable)
  936.    if (aState == sfFocused && !enable) {
  937.     strupr(data);
  938.     drawView();
  939.    TInputLine::setState(aState, enable);
  940. virtual void setState( ushort aState, Boolean enable );
  941.   void
  942.   setState(ushort aState, Boolean enable)
  943.    if (aState == sfFocused && !enable) {
  944.     strupr(data);
  945.     drawView();
  946.    TInputLine::setState(aState, enable);
  947.       The TStringInputLine class is derived from Turbo Vision's
  948.    TInputLine class. TStringInputLine is declared in TSTRINP.HPP,
  949.    and defined in TSTRINP.CPP.
  950.       This file is hereby released by the author to the public
  951.    domain. Use it as you will.
  952.    Author:      Michael Joseph Newton
  953.    Date:        01/17/92
  954.    Address:     17874 Marygold Ave. #32
  955.                 Bloomington, CA 92316
  956.    Phone:       (714) 877-4655
  957.    CompuServe:  70402,531 (as Michael J. Newton)
  958.    RelayNet:    ->ECTECH (as Mick Newton)
  959.    All questions or comments will be greatly appreciated!
  960.       The TStringInputLine class is derived from Turbo Vision's
  961.    TInputLine class. TStringInputLine is declared in TSTRINP.HPP,
  962.    and defined in TSTRINP.CPP.
  963.       This file is hereby released by the author to the public
  964.    domain. Use it as you will.
  965.    Author:      Michael Joseph Newton
  966.    Date:        01/17/92
  967.    Address:     17874 Marygold Ave. #32
  968.                 Bloomington, CA 92316
  969.    Phone:       (714) 877-4655
  970.    CompuServe:  70402,531 (as Michael J. Newton)
  971.    RelayNet:    ->ECTECH (as Mick Newton)
  972.    All questions or comments will be greatly appreciated!
  973. *new TSubMenu("~\360~", kbAltSpace, hcSystem) +
  974. left,D
  975. right,D
  976. string
  977.